package org.example;


import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

import java.util.concurrent.ExecutorService;

public class MainApp {
    public static void main(String[] args) {
        // 1. 创建基于注解的 Spring 容器
        ApplicationContext context = new AnnotationConfigApplicationContext(AppConfig.class);

        // 2. 获取线程池 Bean
        ExecutorService executorService = context.getBean(ExecutorService.class);

        // 3. 获取任务 Bean
        TaskRunner task = context.getBean(TaskRunner.class);

        // 4. 提交任务到线程池
        executorService.submit(task);

        // 5. 关闭线程池（等待任务执行完）
        executorService.shutdown();
    }
}
